<style type="text/css">
#cas
{
    background: #fbfbfb;
    border: thin solid rgb(0,0,0);
    padding-left: 1%;
}
</style>
<div id="cas"> 
<?php
    include("config.php");
    $descriptorspec = array(
        0 => array("pipe", "r"),
        1 => array("pipe", "w"),
        2 => array("file", $DOCUMENT_ROOT."/error-scilab-output.txt", "a")
    );

    $env = array('HOME' => $DOCUMENT_ROOT,'DISPLAY' => '0', 'LD_ASSUME_KERNEL' => '2.4.1');

    $process = proc_open('/usr/local/maple/bin/maple', $descriptorspec, $pipes, @$cwd, $env);
    if (is_resource($process)) {
        $str1 = array("%","'");
        $str2 = array("\%","''");
        fwrite($pipes[0],"?".$_GET['comando'].";\n");
        fclose($pipes[0]);
        echo "<pre>\n"; 
        echo stream_get_contents($pipes[1]);
        echo "\n</pre>\n";
        fclose($pipes[1]);
        $return_value = proc_close($process);
    }
?>
</div>
